package com.to8to.scene.aop;

import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.to8to.scene.util.LogUtil;

/**
 * 记录日志
 * @author Ervin.zhang
 */
public class LogAdviceImpl implements LogAdvice
{

    public static Logger logger = LoggerFactory.getLogger(LogAdviceImpl.class);

    @Override
    public void before(Method method, Object[] args)
    {
        logger.debug("进入 {} 方法, 参数列表：{}", method.getName(), args);
    }

    @Override
    public void after(Method method, Object[] args, long millSeconds, Object retVal)
    {
        logger.debug("{} 执行耗时：{}毫秒", method.getName(), millSeconds);
    }

    @Override
    public void tryCatch(Exception e) throws Throwable
    {
        logger.error("error_type:{},error_message:{},error_stack:{}", e.getClass(), e.getMessage(), LogUtil.logStackTrace(e));
        throw e;
    }
}
